<%--
  Created by IntelliJ IDEA.
  User: HeiMei
  Date: 2015/11/11
  Time: 14:05
  To change this template use File | Settings | File Templates.
--%>

<%@ page language="java" contentType="text/html;charset=utf-8" pageEncoding="utf-8" %>
<!DOCTYPE HTML>
<html>

<script type="text/javascript" src="<%=request.getContextPath()%>/resources/js/public/mapObj.js"></script>
<head>
    <title></title>
</head>
<style type="text/css">
    .anchorBL {
        display: none;
    }

    .divBtnr {
        float: left;
        position: absolute;
        margin-left: 400px;
        margin-top: 5px;
    }

</style>
<body>
<input type="hidden" value="${lng}" id="plocallng"/>
<input type="hidden" value="${lat}" id="plocallat"/>

<div class="container" id="oneMap" style='width: 500px;height:425px;'>
</div>
<div class="divBtnr">
    <button onClick="pointsave();" class="btn btn-primary size-S radius"
            type="button"><i class="Hui-iconfont">&#xe632;</i> 保存
    </button>
</div>
</body>
</html>
<%@include file="../../head-ui.jsp" %>
<script type="text/javascript">

    $(function () {
        var lng = parseFloat(${lng});
        var lat = parseFloat(${lat});
        if (parent.$('#lng').val() != "" && parent.$('#lat').val() != "") {
            mapObj = new MapEditor("oneMap", null)
            var poi = new BMap.Point(lng, lat)
            mapObj.map.centerAndZoom(poi, 16);  // 初始化地图,设置中心点坐标和地图级别
            var marker = new BMap.Marker(poi);// 创建标注
            mapObj.map.addOverlay(marker);
            marker.enableDragging();
            marker.addEventListener("dragend", function (e) {
                $("#plocallng").val(e.point.lng);
                $("#plocallat").val(e.point.lat);
            })
        }
        else {
            mapObj = new MapEditor("oneMap", null)
            var poi = new BMap.Point(121.42, 31.22)
            mapObj.map.centerAndZoom(poi, 16);  // 初始化地图,设置中心点坐标和地图级别
            var marker = new BMap.Marker(poi);// 创建标注
            mapObj.map.addOverlay(marker);
            marker.enableDragging();
            marker.addEventListener("dragend", function (e) {
                $("#plocallng").val(e.point.lng);
                $("#plocallat").val(e.point.lat);
            })
        }
    });

    function pointsave() {
        var lng = $("#plocallng").val();
        var lat = $("#plocallat").val();
        parent.$('#lng').val(lng);
        parent.$('#lat').val(lat);
        layer_close();
    }
</script>
